/**
 * Created by qipia on 2017/3/6.
 */
//命名空间
var crm = {};
(function () {
    crm = {
        /**
         * 自定义弹窗()
         * @param id       页面上自己自定义HTML内容的容器ID
         * @param css       需要额外添加的css样式
         * @param data      弹窗头部信息框
         * @returns {string}
         */
        // dialog: function (id, css, data) {
        //     if(!id){
        //        return null;
        //     }
        //     css = css?css:"w5h6";
        //     data = data ? data :"";
        //     var section = document.createElement("section");
        //     section.setAttribute("id","maskId");
        //     document.body.appendChild(section);
        //     var maskId = document.querySelector("#maskId");
        //     var maskcontent = '<div class="mask"><div id="maskcontent" class="alignCenter '+css+'"><span id="spanId" class="rightTop"><i class="fa fa-times record_exit"></i></span><div class="headId"><p>'+data+'</p></div></div><div>';
        //     maskId.innerHTML+=maskcontent;
        //     var closeSpan=document.querySelector(".rightTop");
        //     var mask = document.querySelector("#maskcontent");
        //     var maskDiv = document.getElementById(id);
        //     mask.appendChild(maskDiv);
        //     closeSpan.addEventListener("click",function(){
        //        $(".mask").css("display","none");
        //     })
        //     return maskcontent;
        // }
        // ,
        /**
         * alert(信息提示弹出框)
         * @param text                   弹出层的文本内容
         * @param type                   图标类型，默认null，可以填写success、error、warning、info、question
         * @param callback               按下确认键后执行的函数
         * @param all_callback           按到按钮之外，弹窗消失时执行函数
         * @param showCancelButton       是否显示取消按钮
         */
        alert: function (text, type, callback, showCancelButton, all_callback) {
            now_text = text ? text : "你确定么?";
            now_type = type ? type : null;
            now_callback = callback ? callback : function () {
            };
            all_callback = all_callback ? all_callback : function (dismiss) {
            };
            now_showCancelButton = showCancelButton ? showCancelButton : false;
            if (typeof(arguments[1]) == "function") {
                now_type = null;
                now_callback = arguments[1];
                now_showCancelButton = arguments[2];
            }
            swal({
                text: now_text,
                type: now_type,
                showCancelButton: now_showCancelButton,
                confirmButtonColor: '#3085d6',
                cancelButtonColor: '#d33',
                confirmButtonText: '确定',
                cancelButtonText: '取消',
                confirmButtonClass: 'btn btn-success',
                cancelButtonClass: 'btn btn-danger',
                buttonsStyling: false
            }).then(function () {
                now_callback();
            }, all_callback)
        },
        input_alert: function () {
            swal({
                title: "An input!",
                text: "Write something interesting:",
                type: "input",
                showCancelButton: true,
                closeOnConfirm: false,
                animation: "slide-from-top",
                inputPlaceholder: "Write something"
            }, function (inputValue) {
                if (inputValue === false) return false;
                if (inputValue === "") {
                    swal.showInputError("You need to write something!");
                    return false
                }
                swal("Nice!", "You wrote: " + inputValue, "success");
            });
        }

    }
})(crm || {});